package com.allen.study.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 文档配置
 *
 * @author AllenSun
 * @since 2025-04-23 20:46
 */
@Configuration
public class SpringDocConfig {

// Swagger地址：http://localhost:8081/swagger-ui/index.html

    /**
     * 配置 API文档
     *
     * @return API Bean
     */
    @Bean
    public OpenAPI openAPI() {
        License license = new License();
        license.name("hzyatop")
                .url("http://www.hzyatop.com");

        Info info = new Info();
        info.title("杭州雅拓信息")
                .description("接口文档")
                .version("1.0")
                .license(license);

        return new OpenAPI()
                .info(info);
    }

    /**
     * 配置 API分组
     *
     * @return API分组Bean
     */
    @Bean
    public GroupedOpenApi groupedOpenApi() {
        return GroupedOpenApi.builder()
                .group("杭州雅拓信息")
                .pathsToMatch("/**")
                .build();
    }
}